package com.ruoyi.system;

import org.apache.poi.xwpf.converter.pdf.PdfConverter;
import org.apache.poi.xwpf.converter.pdf.PdfOptions;
import org.apache.poi.xwpf.usermodel.XWPFDocument;

import java.io.*;

/**
 * @Classname utils
 * @Description TODO
 * @Date 2025/3/31 12:13
 * @Created by xxx
 */
public class utils {
    public static void wordToPdf(String docFile,String pdfFile) throws IOException {
        XWPFDocument document;
        InputStream doc = new FileInputStream(docFile);
        document = new XWPFDocument(doc);
        PdfOptions options = PdfOptions.create();
        OutputStream out = new FileOutputStream(pdfFile);
        PdfConverter.getInstance().convert(document, out, options);
        doc.close();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        String docFile = "C:\\Users\\许家禄\\Desktop\\记录纪要（经分会）\\2024年1月生产经营分析会\\定稿.docx";
        String pdfFile = "C:\\Users\\许家禄\\Desktop\\记录纪要（经分会）\\2024年1月生产经营分析会\\定稿.pdf";
        wordToPdf(docFile,pdfFile);
    }
}
